package com.chb.controller;

import com.chb.annotation.LogAnnotation;
import com.chb.model.entity.OutLibrayTransfer;
import com.chb.model.vo.BranchGoodsVo;
import com.chb.model.vo.Result;
import com.chb.model.vo.TransferVo;
import com.chb.service.OutLibrayTransferService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: 陈海彬
 * @date: Created in 2023/10/1 15:57
 * @description:
 * @modified By:
 * @version:
 */
@RestController
@RequestMapping("/outLibrayTransfer")
public class OutLibrayTransferController {
    @Autowired
    private OutLibrayTransferService outLibrayTransferService;

    /**
     * @param page     当前页
     * @param pageSize 每页展示数量
     * @param branchid 分店id
     * @create by: 陈海彬
     * @description: 获取平调的全部信息
     * @create time: 2023/10/1 15:58
     */
    @GetMapping("/getAllInfo")
    public Result getAllInfo(Integer page, Integer pageSize, Integer branchid) {
        return outLibrayTransferService.getAllInfo(page, pageSize, branchid);
    }

    /**
     * @param cid 出库编号
     * @return com.chb.model.vo.Result
     * @create by: 陈海彬
     * @description: 通过出库编号查找详细信息
     * @create time: 2023/10/1 16:59
     */
    @GetMapping("/getDetails")
    public Result getDetailsByCid(Integer page, Integer pageSize, Integer cid) {
        return outLibrayTransferService.getDetailsByCid(page, pageSize, cid);
    }


    /**
     * @param page     当前页
     * @param pageSize 每页展示的条目
     * @return com.chb.model.vo.Result
     * @create by: 陈海彬
     * @description: 获取平调审核信息
     * @create time: 2023/10/1 19:00
     */
    @GetMapping("/getHorizontalAudit")
    public Result getHorizontalAudit(Integer page, Integer pageSize) {
        return outLibrayTransferService.getHorizontalAudit(page, pageSize);
    }

    /**
     * @param branchid          平调分店id
     * @param branchGoodsVoList 平调商品数据
     * @return com.chb.model.vo.Result
     * @create by: 陈海彬
     * @description: 添加平调审核数据
     * @create time: 2023/10/1 19:54
     */
    @PostMapping("/addOutLibrayTransfer")
    @LogAnnotation(business_type = "添加平调出库商品")
    public Result addOutLibrayTransfer(Integer branchid, @RequestBody List<BranchGoodsVo> branchGoodsVoList) {
        return outLibrayTransferService.addOutLibrayTransfer(branchid, branchGoodsVoList);
    }

    /**
     * @param cid     审核的id
     * @param status  状态 1.代表通过审核，2代表驳回审核
     * @param remarks 驳回审核的信息
     * @return com.chb.model.vo.Result
     * @create by: 陈海彬
     * @description: 修改审核的状态
     * @create time: 2023/10/1 21:16
     */
    @PostMapping("/updateOutLibrayTransfer")
    @LogAnnotation(business_type = "进行平调审核")
    public Result updateOutLibrayTransfer(@RequestBody TransferVo transferVo) {
        return outLibrayTransferService.updateOutLibrayTransfer(transferVo.getCid(),
                transferVo.getStatus(), transferVo.getRemarks());
    }
}